/*
 ============================================================================
 Name        : EGOS.c
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#include <stdio.h>
#include <stdlib.h>

#include <egos_logging.h>
#include <ring_buffer.h>

int main(void) {
	puts("!!!Hello World!!!"); /* prints !!!Hello World!!! */

	RingBuffer *buf = RingBufferCreate(8, 0, 0);
	int vals[7] = {3, 4, 5 ,6, 0, 1, 2};
	int i;
	for(i = 0; i<7;i++)
		RingBufferWriteEntry(buf, (void**)vals[i]);

	RingBufferDump(buf);

	RingBufferWriteEntry(buf, (void**)33);

	RingBufferDump(buf);

	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);
	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);
	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);
	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);
	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);
	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);
	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);
	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);

	RingBufferDump(buf);

	RingBufferWriteEntry(buf, (void**)33);

	RingBufferWriteEntry(buf, (void**)44);

	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);

	RingBufferWriteEntry(buf, (void**)55);

	if(RingBufferReadEntry(buf, (void**)&i))
		PRINTN("read %d from the buffer", i);

	RingBufferDump(buf);

	return EXIT_SUCCESS;
}
